<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>正则表达式</title>
	</head>
	<body>
		<input type="text" name="" id="" value="" />
		<script type="text/javascript">
			var inp = document.querySelector("input");
			inp.addEventListener('keyup',function(){
				inp.value = inp.value.replace(/[^0-9]/g,'');
			})
		</script>
	</body>
</html>
